<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />

		<title>媒体预算列表</title>

		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
		<meta http-equiv="description" content="This is my page" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/css/common.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/tag.css" />
		<link rel="stylesheet" type="text/css" 
			href="<%=path%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css" />
		<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"
			src="<%=path%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js"></script>
		<script type="text/javascript">
			$(function(){
				//
		        //selectNav('nav7');
		        //
		        $("#year").change(function(){
		        	var year = $(this).val();
		        	if(year != ""){
		        		$("#planYear").val(year);
		        		$('#form1').submit();
		        	}
				});
				
		      //重置按鈕事件
				$('#btnRe').click(function(){
					$('#keyword').val('输入媒体名称关键字检索');
					var objSelect =$('#year option').length; //设置年份
					for(var i=0;i<objSelect;i++)
					{   //alert(i);
						if(i == 0)
						{
				            $("#year").get(0).options[i].selected = true;  
				            $("#planYear").val($("#year").get(0).options[i].value);
				            //alert($("#year").val());
				            break;
						 }
					 }      
				});
		    });

			
		    //
		    function pageSub(currentPage) {
				var reg = /^\d*?$/;
				var total = ${page.totalPages};
				if(reg.test(currentPage)){
				 	if(currentPage > total){
				 		currentPage = total;
					 }
					 $("#currentPage").val(currentPage);
					 $('#form1').submit();
				} else {
					alert("请输入数字!");
				}
			}
			//
			function submitForm(){
				var keyword = $.trim($("#keyword").val());
				if(keyword != "" && keyword != "输入媒体名称关键字检索"){
					var reg = /^[\s\dA-Za-z\u4E00-\u9FA5]+$/;
					if(!reg.test(keyword)){
						alert("关键字中含有非法字符！");
					}else{
						$("#mediaName").val(keyword);
						//提交
						$('#form1').submit();
					}	
				}else{
					$("#mediaName").val("");
					$('#form1').submit();
				}
			}
		</script>
	</head>

	<body>
		<!-- 顶栏start -->
		<jsp:include page="/jsp/common/top.jsp"></jsp:include> 
		<!-- 顶栏end -->
	
		<!-- 顶部start -->
		<div id="main">
			<div class="body">
				<!-- 导航菜单 -->
				<jsp:include page="../common/nav.jsp"></jsp:include>
				<!-- 主体 -->
				<div class="main_body">
					<form id="form1" action="mediaBudgetList.action" method="post">
					<table class="condition bg1"
						style="width: 100%; font-size: 14px; font-weight: bold; color: #000000;"
						align="center">
						<tr>
							<td width="20%" style="height: 40px;text-align: center;">
									&nbsp;&nbsp;&nbsp;&nbsp;
							        <label>年度：</label> 
	                       	        &nbsp;&nbsp;
	                       	        <s:select id="year" list="years" value="sourcePlanYear.planYear"></s:select>
							</td>
							<td width="30%" style="height: 40px; text-align: center;">
								<s:if test="sourcePlanYear.mediaName == null || sourcePlanYear.mediaName == ''">
									<input id="keyword" type="text" class="text" value="输入媒体名称关键字检索" onfocus="if($(this).val() == '输入媒体名称关键字检索'){$(this).val('');}" />
								</s:if>
								<s:else>
									<input id="keyword" type="text" class="text" value="${sourcePlanYear.mediaName }" onfocus="if($(this).val() == '输入媒体名称关键字检索'){$(this).val('');}" />
								</s:else>
								&nbsp;&nbsp;&nbsp;
								<input type="button" class="btn-title" value="搜索" onclick="submitForm();" />
								&nbsp;&nbsp;&nbsp;&nbsp;
								<input type="button" id="btnRe" class="btn-title" value="重置" />
							</td>
							<td style="height: 40px; text-align: right;">
								<input type="button" class="btn-title" value="预算录入"
									onclick="window.location.href='mediaPlanCountAdd.action'" />
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								
								<input type="button" class="btn-title" value="返回"
									onclick="window.location.href='budgetList.action'" />
									&nbsp;&nbsp;&nbsp;
							</td>
						</tr>
					</table>
					<input type="hidden" id="currentPage" name="currentPage" />
					<input type="hidden" id="planYear" name="sourcePlanYear.planYear" value="${sourcePlanYear.planYear }" />
					<input type="hidden" id="city" name="sourcePlanYear.city" value="${sourcePlanYear.city }" />
					<input type="hidden" name="sourcePlanYear.costType" value="${sourcePlanYear.costType }" />
					<input type="hidden" name="sourcePlanYear.costSubtype" value="${sourcePlanYear.costSubtype }" />
					<input type="hidden" id="mediaName" name="sourcePlanYear.mediaName" />
					</form>

					<div id="list_div">
						<table class="table_list" style="width: 100%;">
							<tr>
								<th rowspan="2">
									媒体名称
								</th>
								<th rowspan="2">
									费用类型
								</th>
								<th rowspan="2">
									费用子类
								</th>
								<th rowspan="2">
									计划投放总量
								</th>
								<th rowspan="2">
									固定资源<br />计划投放量
								</th>
								<th rowspan="2">
									浮动资源<br />计划投放量
								</th>
								<th rowspan="2">
									购买资源<br />计划投放量
								</th>
								<th colspan="3">
									赠送资源计划投放量
								</th>
								<th rowspan="2">
									操作
								</th>
							</tr>
							<tr>
								 
								<th>
									常规赠送
								</th>
								<th>
									增量赠送
								</th>
								<th>
									一次性年度返还
								</th> 
							</tr>
							<s:iterator value="sourcePlanYears">
							<tr>
								<td>${mediaName }</td>
								<td>${costType }</td>
								<td>${costSubtype }</td>
								<td><fmt:formatNumber value='${planTotalAmount}' maxFractionDigits ="3"/></td>
								<td><fmt:formatNumber value='${fixSourceAmount}' maxFractionDigits ="3"/></td>
								<td><fmt:formatNumber value='${floatSourceAmount}' maxFractionDigits ="3"/></td>
								<td><fmt:formatNumber value='${unPromotionAmount}' maxFractionDigits ="3"/></td>
								<td><fmt:formatNumber value='${promotionAmount}' maxFractionDigits ="3"/></td>
								<td><fmt:formatNumber value='${increPromotionAmount}' maxFractionDigits ="3"/></td>
								<td><fmt:formatNumber value='${returnSourceAmount}' maxFractionDigits ="3"/></td>
								<td>  
									<a href="updateResPut.action?sourceId=${id }" title="编辑">
										<img src="images/modify.gif" alt="编辑" />
									</a>
									<a href="viewResPut.action?sourceId=${id }" title="详情">
										<img src="images/detail.gif" alt="详情" />
									</a>
									<a href="deleteBudget?sourcePlanYear.id=${id }&sourcePlanYear.planYear=${sourcePlanYear.planYear }&sourcePlanYear.city=${sourcePlanYear.city }&sourcePlanYear.costType=${sourcePlanYear.costType }&sourcePlanYear.costSubtype=${sourcePlanYear.costSubtype }" onclick="return confirm('确定删除该条记录？');"> 
										<img src="images/delete.gif" alt="删除" /> 
									</a>
								</td>
								</tr>
							</s:iterator>
						</table>
						<!-- 分页start -->
						<jsp:include page="/jsp/common/page.jsp"></jsp:include>
						<!-- 分页end -->
					</div>
				</div>
			</div>
		</div>
		<!-- 顶部end -->
		
		<!-- 底部start -->
		<jsp:include page="/jsp/common/bottom.jsp"></jsp:include> 
		<!-- 底部end -->
	</body>
</html>
